package org.example;

import cn.hserver.core.ioc.annotation.Bean;
import cn.hserver.plugin.gateway.business.BusinessHttp7;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;

import java.net.InetSocketAddress;
import java.net.SocketAddress;

@Bean
public class MyBusinessHttp7 extends BusinessHttp7 {
    @Override
    public SocketAddress getProxyHost(ChannelHandlerContext ctx, Object o, SocketAddress sourceSocketAddress) {
        return new InetSocketAddress("127.0.0.1",8888);
    }

    @Override
    public String requestIgnoreUrls() {

        return "/upload";
    }

    @Override
    public String responseIgnoreUrls() {
        return "/download";
    }

    @Override
    public Object in(ChannelHandlerContext ctx, Object obj) {
        System.out.println(obj.getClass());
        return super.in(ctx, obj);
    }

    @Override
    public Object out(Channel channel, Object obj) {
        System.out.println(obj.getClass());
        return super.out(channel, obj);
    }


    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        cause.printStackTrace();
    }
}
